[−][src]Crate sysinfo
sysinfo
is a crate used to get a system's information.
Before any attempt to read the different structs' information, you need to update them to get up-to-date information.
Examples
use sysinfo::{ProcessExt, SystemExt}; let mut system = sysinfo::System::new(); // First we update all information of our system struct. system.refresh_all(); // Now let's print every process' id and name: for (pid, proc_) in system.get_process_list() { println!("{}:{} => status: {:?}", pid, proc_.name(), proc_.status()); } // Then let's print the temperature of the different components: for component in system.get_components_list() { println!("{:?}", component); } // And then all disks' information: for disk in system.get_disks() { println!("{:?}", disk); } // And finally the RAM and SWAP information: println!("total memory: {} KiB", system.get_total_memory()); println!("used memory : {} KiB", system.get_used_memory()); println!("total swap : {} KiB", system.get_total_swap()); println!("used swap : {} KiB", system.get_used_swap());
Structs
Component | More information can be found at [kernel.org][k]. |
Disk | Struct containing a disk information. |
NetworkData | Contains network information. |
Process | Struct containing a process' information. |
Processor | Struct containing a processor information. |
RefreshKind | Used to determine what you want to refresh specifically on [ |
System | Structs containing system's information. |
Enums
DiskType | Enum containing the different handled disks types. |
ProcessStatus | Enum describing the different status of a process. |
Signal | An enum representing signal on UNIX-like systems. |
Traits
AsU32 | Trait to have a common fallback for the |
ComponentExt | Getting a component temperature information. |
DiskExt | Contains all the methods of the |
NetworkExt | Getting volume of incoming and outgoing data. |
ProcessExt | Contains all the methods of the |
ProcessorExt | Contains all the methods of the |
SystemExt | Contains all the methods of the [ |
Functions
get_current_pid | Returns the pid for the current process. |
set_open_files_limit | This function is only used on linux targets, on the other platforms it does nothing. |
Type Definitions
Pid | Process id. |